import { inject, observer } from 'mobx-react'
import React, { Component } from 'react';
@inject('counter')
@observer

class App extends Component{
  componentDidMount(){
    const { getData } = this.props.counter
    getData()
  }
  render(){
    const { counter } = this.props
    return (
      <div className="App">
        <button onClick={counter.decrement}>-</button>
        <span>{counter.count}</span>
        <button onClick={counter.increment}>+</button>
        <span>{counter.getResult}</span>
        <input value={counter.username} onChange={e => counter.changeUsername(e.target.value)}></input>
        <div>
          {counter.users.map(user => (
            <div key={user.id}>
              <span>{user.id}</span>
              <span>{user.login}</span>
            </div>
          ))}
        </div>
      </div>
    )
  }
}

export default App;
